package yxy.game.pm2.proto;

import java.io.File;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;

import yxy.apple.util.JSONUtility;

public class CheckProto {
	public static void main(String[] args) {
		try {
			JSONArray message = JSONUtility.readArray(new File(ProtobufCompiler.SRC_PROTO_DIR + "/game.json"));
			int size = message.size();
			String desc = null;
			String messagefile = null;
			for (int i = 0; i < size; i++) {
				JSONObject field = JSONUtility.getJSONObject(message, i, null);
				String value = JSONUtility.getString(field, "value", null);
				String comment = JSONUtility.getString(field, "comment", null);
				String name = JSONUtility.getString(field, "name", null);
				JSONArray descs = field.getJSONArray("desc");

				if (!value.endsWith("A")) {
					continue;
				}

				if (descs.size() > 0) {
					desc = descs.getString(0);
				}
				if (descs.size() > 1) {
					messagefile = descs.getString(1);
				}
//				String classname = "yxy.game.pm2.message." + messagefile + "$" + name + "Request";

				String classname = "CMD_"+name;
				
				try {
					Class.forName(classname);
				} catch (ClassNotFoundException e) {
					System.err.println("\""+classname+"\",");
				}
			}
			System.err.println("Done!!");
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}
